package cst.a729yt.zyfypt_729yt.Fragment;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;

import cst.a729yt.zyfypt_729yt.Adapter.VideoAdapter;
import cst.a729yt.zyfypt_729yt.Bean.VideoBean;
import cst.a729yt.zyfypt_729yt.R;
import cst.a729yt.zyfypt_729yt.ResModel;
import cst.a729yt.zyfypt_729yt.ytListener;


/**
 * A simple {@link Fragment} subclass.
 */
public class Video_NewFragment extends Fragment {


    private RecyclerView recyclerView;
    private VideoAdapter adapter;
    private List<VideoBean> list;
    private RecyclerView.LayoutManager layoutManager;
    private ytListener<List<VideoBean>> listener;
    private ResModel model;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_video_new, container, false);
        recyclerView = (RecyclerView) view.findViewById(R.id.newVideo_rec);
        adapter = new VideoAdapter(getActivity());
        list = new ArrayList<VideoBean>();
        layoutManager = new LinearLayoutManager(getActivity());
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.setAdapter(adapter);
        listener = new ytListener<List<VideoBean>>() {
            @Override
            public void onResponse(List<VideoBean> l) {
                adapter.setList(l);
            }

            @Override
            public void onFail(String msg) {

            }
        };
        model = new ResModel("gson");
        model.getList("video", 1, listener);
        return view;
    }

}

